package talk.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;

import com.talk.debby.talk.R;

import base.BaseActivity;

public class SplashActivity extends BaseActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
            finish();
            Intent intent = new Intent(SplashActivity.this, HomeActivity.class);
            startActivity(intent);
            return;
        }
        setContentView(R.layout.layout_splash);
    }

    @Override
    protected void onResume() {
        super.onResume();
        gotoMain();
    }

    private void gotoMain() {

        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                startActivity(intent);
            }
        }, 2000);

    }
}
